package com.xuelang.config;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

import javax.sql.DataSource;

/**
 * <p>Quartz数据源配置类</p>
 *
 * @author : yixin.lys
 * @date : 2024-06-17 13:29
 **/
@Configuration
public class QuartzDataBaseConfig {

    @Bean
    public SchedulerFactoryBean schedulerFactoryBean(@Qualifier("dataSource") DataSource dataSource) {
        SchedulerFactoryBean factory = new SchedulerFactoryBean();
        factory.setDataSource(dataSource);
        factory.setOverwriteExistingJobs(true);
        factory.setStartupDelay(15);
        factory.setAutoStartup(true);
        return factory;
    }

}
